import React from 'react'

import {connect} from 'react-redux'

class Books extends React.Component {


    componentDidMount() {
        console.log(this.props)
    }

    myBookschange=()=>{
        console.log('change')
        this.props.myBooksAdd()
    }
  render() {

   console.log(this.props)
    let  {mybooks,msg}=this.props
    return (
      <div>

          <div>{mybooks}</div>

          <div>{msg}</div>


        <h2>Books</h2>

        <button  onClick={this.myBookschange}>++</button>
      </div>
    )
  }
}


const  mapStateToProps=({BooksReducer})=>{
   


    return  {
        mybooks:'我是书',
        ...BooksReducer
    }

}

const  mapDispatchToProps=(dispatch)=>{
    return {

        myBooksAdd:()=>dispatch({type:'ADD'})



    }

}

export default connect(mapStateToProps,mapDispatchToProps)(Books);
